// 引入Sequelize模块
const Sequelize = require('sequelize');

// 引入数据库实例
const db = require('../db');

// 定义登录日志model
const loginLog = db.define('loginLog', {
    objectId: {
        type: Sequelize.STRING(20),
        allowNull: false,
        unique: true,
        primaryKey: true
    },

    userId: {
        type: Sequelize.STRING(20),
        allowNull: false,
        comment: "用户ID",
    },

    loginTime: {
        type: Sequelize.DATE,
        comment: "登录时间",
    },

    createdAt: {
        type: Sequelize.DATE,
    },

    updatedAt: {
        type: Sequelize.DATE,
    },
}, {
    // 是否支持驼峰
    underscored: false,
    // MySQL数据库表名
    tableName: 'loginLog',
});

/*(async () => {
    await loginLog.sync({
        alter: true,
    });
    console.log("loginLog字段同步成功！");
})();*/

module.exports = {
    loginLog
};
